package top.superflow.lang

import org.apache.commons.lang3.{StringUtils => ApacheStringUtils}

class StringUtils {
  
}

object StringUtils {
  
  final val EMPTY = ApacheStringUtils.EMPTY
  
  final val DOUBLE_SPACES = "  "
  
  final val SINGLE_SPACES = " "
  
  final val COMMA = ","

  final val COLON = ":"

  final val SEMICOLON = ";"

  final val SLASH = '/'

  final val DOLLAR = '$'
  
  def lowerCase(str : String) : String = {
    ApacheStringUtils.lowerCase(str)
  }
  
  def isBlank(any : CharSequence) : Boolean = {
    ApacheStringUtils.isBlank(any)
  }

  def isNotBlank(any : CharSequence) : Boolean = {
    ! ApacheStringUtils.isBlank(any)
  }
  
  def containsIgnoreCase( str : CharSequence,  searchStr : CharSequence) : Boolean = {
    ApacheStringUtils.containsIgnoreCase(str, searchStr)
  }
  
  def contains( str : CharSequence,  searchStr : CharSequence) : Boolean = {
    ApacheStringUtils.contains(str, searchStr)
  }
  
  def trim(str : String) : String = {
    ApacheStringUtils.trim(str)
  }
  
  def isSynonymEqual(str1 : String, str2 : String) : Boolean = {
    if(str1 == null || str2 == null){
      return false
    }
    
    val cleanStr1 = ApacheStringUtils.lowerCase(ApacheStringUtils.trim(str1))
    val cleanStr2 = ApacheStringUtils.lowerCase(ApacheStringUtils.trim(str2))
    cleanStr1.equals(cleanStr2)
  }
  
  def replaceOnce(text : String, searchString : String, replacement : String) : String = {
    ApacheStringUtils.replaceOnce(text, searchString, replacement)
  }

  def replaceAll(text : String, regex : String, replacement : String) : String = {
    ApacheStringUtils.replace(text, regex, replacement)
  }
  
  def equals(str1 : CharSequence, str2 : CharSequence) : Boolean = {
    ApacheStringUtils.equals(str1, str2)
  }

  def equalsIgnoreCase(str1 : CharSequence, str2 : CharSequence) : Boolean = {
    ApacheStringUtils.equalsIgnoreCase(str1, str2)
  }
  
  def startWith(str : CharSequence, prefix : CharSequence) : Boolean = {
    ApacheStringUtils.startsWith(str, prefix)
  }
  
  def split(str : String, separator : String) : Array[String] = {
    ApacheStringUtils.split(str, separator)
  }

  
  def main(args: Array[String]): Unit = {
    println(ApacheStringUtils.lowerCase(ApacheStringUtils.trim(null)))
  }
  
}